//
//  SJRectCornerView.swift
//  dj-learn-Swift
//
//  Created by Sun Jae on 2022/4/24.
//  Copyright © 2022 S.J. All rights reserved.
//

import UIKit

class SJRectCornerView: UIView {

    var fillColor = UIColor.white
    var cornerRadii: CGSize = .zero
    var roundCorners = UIRectCorner.allCorners
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.clear
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func draw(_ rect: CGRect) {
        guard let context = UIGraphicsGetCurrentContext() else { return }
        let bezierPath = UIBezierPath(roundedRect: rect, byRoundingCorners: roundCorners, cornerRadii: cornerRadii)
        context.addPath(bezierPath.cgPath)
        context.closePath()
        context.setFillColor(fillColor.cgColor)
        context.drawPath(using: .fill)
    }
}
